home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / xachshadow < prev    next >
Encoding:
Text File  |  2000-11-17  |  3.1 KB  |  91 lines

  1. #!/usr/app/bin/perl
  2.  
  3. eval 'exec /usr/app/bin/perl  -S $0 ${1+"$@"}'
  4.     if 0; # not running under some shell
  5.  
  6. eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
  7.     if 0; # not running under some shell
  8. # by Seth Burgess <sjburges@gimp.org>
  9.  
  10. #[Xach] start off with an image, then pixelize it
  11. #[Xach] then add alpha->add layer mask                                   [20:21]
  12. #[Xach] render a checkerboard into the layer mask
  13. #[Xach] duplicate the image. fill the original with black, then blur the layer 
  14. #           mask (i used 30% of pixelize size) and offset it by some value (i 
  15. #           chose 20% of the pixelize size)
  16. #[Xach] duplicate the duplicate, remove the layer mask, move it below everything
  17. #[Xach] then add a new white layer on top, set the mode to multiply, and render 
  18. #           a grid into it at pixelize size
  19. #[Xach] that's a bit roundabout, but it's also in the xcf
  20. #
  21. # Because the way xach does it is a bit ackward, I'm switching it around a bit
  22. # and working from the bottom up..
  23.  
  24. # Revision 1.1: Marc Lehman <pcg@goof.com> added undo capability
  25. # Revision 1.2: Marc Lehman <pcg@goof.com>, changed function name
  26. # Revision 1.3: Seth Burgess <sjburges@gimp.org>, changed location and 
  27. #                 added my email address
  28. #
  29. # Here's the boring start of every script...
  30.  
  31. use Gimp qw(:auto __ N_);
  32. use Gimp::Fu;
  33.  
  34. register "xach_shadows",
  35.          "Xach's Shadows o' Fun",
  36.          "Screen of 50% of your drawing into a dropshadowed layer.",
  37.          "Seth Burgess",
  38.          "Seth Burgess <sjburges\@gimp.org>",
  39.          "2-15-98",
  40.          N_"<Image>/Filters/Map/Xach Shadows...",
  41.          "RGB*, GRAY*",
  42.          [
  43.           [PF_SLIDER,    "block_size",    "The size of the blocks...", 10, [4, 255, 1]],
  44.          ],
  45.          sub {
  46.    my($img,$drawable,$blocksize) =@_;
  47.  
  48.         eval { $img->undo_push_group_start };
  49.  #    $selection_flag = 0;
  50.     if (!$drawable->has_alpha) {
  51.         $drawable->add_alpha;
  52.         }; 
  53. # This only can be applied to an entire image right now..    
  54. #    $selection = $img->selection_save;
  55.     $img->selection_all;
  56.     $oldbackground = gimp_palette_get_background();
  57. # Now the fun begins :) 
  58.     $drawable->plug_in_pixelize($blocksize); 
  59.     $shadowlayer = $drawable->layer_copy(0);
  60.     $img->add_layer($shadowlayer,0);
  61.     $checkmask = $shadowlayer->create_mask(WHITE_MASK);
  62.     $img->add_layer_mask($shadowlayer, $checkmask);
  63.     plug_in_checkerboard ($img, $checkmask, 0, $blocksize);
  64.  
  65.     $frontlayer = $shadowlayer->layer_copy(0);
  66.     $img->add_layer($frontlayer,0);
  67.     gimp_palette_set_background([0,0,0]);
  68.     $shadowlayer->fill(BG_IMAGE_FILL);    
  69.     $checkmask->plug_in_gauss_iir(0.3*$blocksize, 1, 1);
  70.     gimp_channel_ops_offset ($checkmask, 1, 0, 0.2*$blocksize, 0.2*$blocksize);
  71.  
  72.  
  73.     $gridlayer = $img->layer_new($img->width, $img->height, RGBA_IMAGE, "Grid 1", 100, 0);
  74.     $img->add_layer($gridlayer,0);
  75.     $img->selection_all;
  76.     gimp_edit_clear($gridlayer);
  77.     gimp_palette_set_background([255,255,255]);
  78.     gimp_edit_fill($gridlayer, BG_IMAGE_FILL);
  79.     $gridlayer->plug_in_grid((1, $blocksize, 0, [0,0,0], 255) x 3);
  80.  
  81.     gimp_layer_set_mode($gridlayer, 3);
  82. # Clean up stuff
  83.     gimp_palette_set_background($oldbackground);
  84.         eval { $img->undo_push_group_end };
  85.     gimp_displays_flush();
  86.     return();
  87. };
  88.  
  89. exit main;
  90.  
  91.